package com.springboot.study.third;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.StringUtils;

/**
 * @program: study
 * @description: 自定义ImportBeanDefinitionRegistrar实现
 * @author: chengqj
 * @create: 2019-07-09 09:38
 **/
public class MyImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {
    @Override
    public void registerBeanDefinitions(
            AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        BeanDefinition beanDefinition =
                new RootBeanDefinition(ImportBeanDefinitionRegistrarService.class);
        String beanName=StringUtils.uncapitalize(
                ImportBeanDefinitionRegistrarService.class.getSimpleName());
        registry.registerBeanDefinition(beanName,beanDefinition);
    }
}
